package com.rental.web.controller;

import com.rental.common.login.GetIdByToken;
import com.rental.common.result.AjaxResult;
import com.rental.common.util.AuthContextHolder;
import com.rental.model.entity.UserAccount;
import com.rental.web.service.UserAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Map;

@RestController
@Tag(name = "用户账户模块")
@RequestMapping("/user-account")
public class UserAccountController {

    @Autowired
    private UserAccountService userAccountService;

    /**
     * 支付
     * @param userAccount
     * @return
     */
    @Operation(summary = "支付")
    @GetIdByToken
    @PostMapping("pay")
    public AjaxResult<String> pay(@RequestBody UserAccount userAccount){
        return AjaxResult.success(userAccountService.pay(userAccount));
    }


    @Operation(summary = "查询用户账户")
    @GetIdByToken
    @GetMapping("/getUserAccount")
    public AjaxResult<Integer> getUserAccount() {
        Long userId = AuthContextHolder.getUserId();
        return AjaxResult.success(userAccountService.getUserAccount(userId));
    }


    /**
     * 邀请好友
     * @param list
     * @return
     */
    @Operation(summary = "邀请好友")
    @GetIdByToken
    @GetMapping("/invite")
    public AjaxResult<Boolean> invite(@RequestParam ArrayList<Long> list) {
        Long userId = AuthContextHolder.getUserId();
        return AjaxResult.success(userAccountService.invite(list,userId));
    }
    /**
     * 发布信息赠送加速值
     * @return
     */

    @Operation(summary = "发布信息赠送加速值")
    @GetIdByToken
    @GetMapping("/sendAccelerateValueByAddInfo")
    public AjaxResult<Boolean> sendAccelerateValueByAddInfo() {
        Long userId = AuthContextHolder.getUserId();
        return AjaxResult.success(userAccountService.sendAccelerateValueByAddInfo(userId));
    }


}
